﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using RestSharp;

namespace Esign.Net.Input
{
    [Serializable]
    public class Files
    {
        /// <summary>
        /// 验证合同
        /// </summary>
        [Serializable]
        public class Verify : InputBase, IInput
        {
            /// <summary>
            /// 合同模版id
            /// </summary>
            [JsonIgnore]
            public string FileId { get; set; }

            /// <summary>
            /// 流程id
            /// </summary>
            [JsonProperty("signFlowId")]
            public string SignFlowId { get; set; }

            public T Build<T>(T t, Config config) where T : InputBase, new()
            {
                t.ConfigInfo = config;
                //https://open.esign.cn/doc/opendoc/pdf-sign3/yekrnc
                t.Url = $"/v3/files/{FileId}/verify";
                t.ReqType = Method.POST;
                return t;
            }
        }

        /// <summary>
        /// 通过模版创建合同文件
        /// </summary>
        [Serializable]
        public class CreateFileByDocTemplateId : InputBase, IInput
        {
            /// <summary>
            /// 合同模版id
            /// </summary>
            [JsonProperty("docTemplateId")]
            public string DocTemplateId { get; set; }

            /// <summary>
            /// 填充后生成的文件名称（可自定义文件名称）
            ///【注】文件名称不可含有以下9个特殊字符：/ \ : * " < > | ？以及所有emoji表情
            /// </summary>
            [JsonProperty("fileName")]
            public string FileName { get; set; }

            /// <summary>
            /// 控件列表和赋值（控件ID和 控件Key 二选一传值）
            /// </summary>
            [JsonProperty("components")]
            public IList<DTO.Component> Components { get; set; }

            public T Build<T>(T t, Config config) where T : InputBase, new()
            {
                t.ConfigInfo = config;
                //https://open.esign.cn/doc/opendoc/file-and-template3/mv8a3i
                t.Url = $"/v3/files/create-by-doc-template";
                t.ReqType = Method.POST;
                return t;
            }
        }
    }
}
